import{buildCreateApi as Pe,coreModule as Oe}from"@reduxjs/toolkit/query";import"@reduxjs/toolkit";function J(e){return e.type==="query"}function Y(e){return e.type==="mutation"}function z(e,...i){return Object.assign(e,...i)}function q(e){return e.replace(e[0],e[0].toUpperCase())}import{createAction as He,createSlice as ve,createSelector as qe,createAsyncThunk as Ie,combineReducers as Ce,createNextState as Ke,isAnyOf as Ve,isAllOf as _e,isAction as je,isPending as We,isRejected as $e,isFulfilled as Ge,isRejectedWithValue as Ze,isAsyncThunkAction as Je,prepareAutoBatched as Ye,SHOULD_AUTOBATCH as Xe,isPlainObject as $,nanoid as et}from"@reduxjs/toolkit";import{formatProdErrorMessage as fe}from"@reduxjs/toolkit";import"@reduxjs/toolkit";import{QueryStatus as le,skipToken as K}from"@reduxjs/toolkit/query";import{useCallback as V,useDebugValue as ne,useEffect as F,useLayoutEffect as Qe,useMemo as B,useRef as O,useState as re}from"react";import{shallowEqual as Z}from"react-redux";var X=WeakMap?new WeakMap:void 0,ee=({endpointName:e,queryArgs:i})=>{let g="",R=X?.get(i);if(typeof R=="string")g=R;else{let x=JSON.stringify(i,(D,c)=>(c=typeof c=="bigint"?{$bigint:c.toString()}:c,c=$(c)?Object.keys(c).sort().reduce((h,b)=>(h[b]=c[b],h),{}):c,c));$(i)&&X?.set(i,x),g=x}return`${e}(${g})`};var I=Symbol();import{useEffect as ae,useRef as ye,useMemo as pe}from"react";function G(e,i,g,R){let x=pe(()=>({queryArgs:e,serialized:typeof e=="object"?i({queryArgs:e,endpointDefinition:g,endpointName:R}):e}),[e,i,g,R]),D=ye(x);return ae(()=>{D.current.serialized!==x.serialized&&(D.current=x)},[x]),D.current.serialized===x.serialized?D.current.queryArgs:e}import{useEffect as de,useRef as ce}from"react";import{shallowEqual as te}from"react-redux";function C(e){let i=ce(e);return de(()=>{te(i.current,e)||(i.current=e)},[e]),te(i.current,e)?i.current:e}var Te=typeof window<"u"&&window.document&&window.document.createElement?Qe:F,ge=e=>e.isUninitialized?{...e,isUninitialized:!1,isFetching:!0,isLoading:e.data===void 0,status:le.pending}:e;function ie({api:e,moduleOptions:{batch:i,hooks:{useDispatch:g,useSelector:R,useStore:x},unstable__sideEffectsInRender:D,createSelector:c},serializeQueryArgs:h,context:b}){let U=D?t=>t():F;return{buildQueryHooks:M,buildMutationHook:L,usePrefetch:j};function _(t,o,y){if(o?.endpointName&&t.isUninitialized){let{endpointName:u}=o,Q=b.endpointDefinitions[u];h({queryArgs:o.originalArgs,endpointDefinition:Q,endpointName:u})===h({queryArgs:y,endpointDefinition:Q,endpointName:u})&&(o=void 0)}let l=t.isSuccess?t.data:o?.data;l===void 0&&(l=t.data);let s=l!==void 0,r=t.isLoading,n=(!o||o.isLoading||o.isUninitialized)&&!s&&r,a=t.isSuccess||r&&s;return{...t,data:l,currentData:t.data,isFetching:r,isLoading:n,isSuccess:a}}function j(t,o){let y=g(),l=C(o);return V((s,r)=>y(e.util.prefetch(t,s,{...l,...r})),[t,y,l])}function M(t){let o=(s,{refetchOnReconnect:r,refetchOnFocus:n,refetchOnMountOrArgChange:a,skip:u=!1,pollingInterval:Q=0,skipPollingIfUnfocused:p=!1}={})=>{let{initiate:k}=e.endpoints[t],d=g(),f=O(void 0);if(!f.current){let E=d(e.internalActions.internal_getRTKQSubscriptions());f.current=E}let S=G(u?K:s,ee,b.endpointDefinitions[t],t),T=C({refetchOnReconnect:r,refetchOnFocus:n,pollingInterval:Q,skipPollingIfUnfocused:p}),A=O(!1),m=O(void 0),{queryCacheKey:P,requestId:H}=m.current||{},N=!1;P&&H&&(N=f.current.isRequestSubscribed(P,H));let w=!N&&A.current;return U(()=>{A.current=N}),U(()=>{w&&(m.current=void 0)},[w]),U(()=>{let E=m.current;if(typeof process<"u",S===K){E?.unsubscribe(),m.current=void 0;return}let W=m.current?.subscriptionOptions;if(!E||E.arg!==S){E?.unsubscribe();let v=d(k(S,{subscriptionOptions:T,forceRefetch:a}));m.current=v}else T!==W&&E.updateSubscriptionOptions(T)},[d,k,a,S,T,w]),F(()=>()=>{m.current?.unsubscribe(),m.current=void 0},[]),B(()=>({refetch:()=>{if(!m.current)throw new Error(fe(38));return m.current?.refetch()}}),[])},y=({refetchOnReconnect:s,refetchOnFocus:r,pollingInterval:n=0,skipPollingIfUnfocused:a=!1}={})=>{let{initiate:u}=e.endpoints[t],Q=g(),[p,k]=re(I),d=O(void 0),f=C({refetchOnReconnect:s,refetchOnFocus:r,pollingInterval:n,skipPollingIfUnfocused:a});U(()=>{let A=d.current?.subscriptionOptions;f!==A&&d.current?.updateSubscriptionOptions(f)},[f]);let S=O(f);U(()=>{S.current=f},[f]);let T=V(function(A,m=!1){let P;return i(()=>{d.current?.unsubscribe(),d.current=P=Q(u(A,{subscriptionOptions:S.current,forceRefetch:!m})),k(A)}),P},[Q,u]);return F(()=>()=>{d?.current?.unsubscribe()},[]),F(()=>{p!==I&&!d.current&&T(p,!0)},[p,T]),B(()=>[T,p],[T,p])},l=(s,{skip:r=!1,selectFromResult:n}={})=>{let{select:a}=e.endpoints[t],u=G(r?K:s,h,b.endpointDefinitions[t],t),Q=O(void 0),p=B(()=>c([a(u),(T,A)=>A,T=>u],_,{memoizeOptions:{resultEqualityCheck:Z}}),[a,u]),k=B(()=>n?c([p],n,{devModeChecks:{identityFunctionCheck:"never"}}):p,[p,n]),d=R(T=>k(T,Q.current),Z),f=x(),S=p(f.getState(),Q.current);return Te(()=>{Q.current=S},[S]),d};return{useQueryState:l,useQuerySubscription:o,useLazyQuerySubscription:y,useLazyQuery(s){let[r,n]=y(s),a=l(n,{...s,skip:n===I}),u=B(()=>({lastArg:n}),[n]);return B(()=>[r,a,u],[r,a,u])},useQuery(s,r){let n=o(s,r),a=l(s,{selectFromResult:s===K||r?.skip?void 0:ge,...r}),{data:u,status:Q,isLoading:p,isSuccess:k,isError:d,error:f}=a;return ne({data:u,status:Q,isLoading:p,isSuccess:k,isError:d,error:f}),B(()=>({...a,...n}),[a,n])}}}function L(t){return({selectFromResult:o,fixedCacheKey:y}={})=>{let{select:l,initiate:s}=e.endpoints[t],r=g(),[n,a]=re();F(()=>()=>{n?.arg.fixedCacheKey||n?.reset()},[n]);let u=V(function(W){let v=r(s(W,{fixedCacheKey:y}));return a(v),v},[r,s,y]),{requestId:Q}=n||{},p=B(()=>l({fixedCacheKey:y,requestId:n?.requestId}),[y,n,l]),k=B(()=>o?c([p],o):p,[o,p]),d=R(k,Z),f=y==null?n?.arg.originalArgs:void 0,S=V(()=>{i(()=>{n&&a(void 0),y&&r(e.internalActions.removeMutationResult({requestId:Q,fixedCacheKey:y}))})},[r,y,n,Q]),{endpointName:T,data:A,status:m,isLoading:P,isSuccess:H,isError:N,error:w}=d;ne({endpointName:T,data:A,status:m,isLoading:P,isSuccess:H,isError:N,error:w});let E=B(()=>({...d,originalArgs:f,reset:S}),[d,f,S]);return B(()=>[u,E],[u,E])}}}import{batch as Re,useDispatch as De,useSelector as me,useStore as xe}from"react-redux";import{createSelector as Se}from"reselect";var se=Symbol(),oe=({batch:e=Re,hooks:i={useDispatch:De,useSelector:me,useStore:xe},createSelector:g=Se,unstable__sideEffectsInRender:R=!1,...x}={})=>({name:se,init(D,{serializeQueryArgs:c},h){let b=D,{buildQueryHooks:U,buildMutationHook:_,usePrefetch:j}=ie({api:D,moduleOptions:{batch:e,hooks:i,unstable__sideEffectsInRender:R,createSelector:g},serializeQueryArgs:c,context:h});return z(b,{usePrefetch:j}),z(h,{batch:e}),{injectEndpoint(M,L){if(J(L)){let{useQuery:t,useLazyQuery:o,useLazyQuerySubscription:y,useQueryState:l,useQuerySubscription:s}=U(M);z(b.endpoints[M],{useQuery:t,useLazyQuery:o,useLazyQuerySubscription:y,useQueryState:l,useQuerySubscription:s}),D[`use${q(M)}Query`]=t,D[`useLazy${q(M)}Query`]=o}else if(Y(L)){let t=_(M);z(b.endpoints[M],{useMutation:t}),D[`use${q(M)}Mutation`]=t}}}}});export*from"@reduxjs/toolkit/query";import{formatProdErrorMessage as Ae}from"@reduxjs/toolkit";import{configureStore as Be}from"@reduxjs/toolkit";import{useContext as he}from"react";import{useEffect as be}from"react";import ue from"react";import{Provider as ke,ReactReduxContext as Ee}from"react-redux";import{setupListeners as Me}from"@reduxjs/toolkit/query";function Ue(e){let i=e.context||Ee;if(he(i))throw new Error(Ae(35));let[R]=ue.useState(()=>Be({reducer:{[e.api.reducerPath]:e.api.reducer},middleware:x=>x().concat(e.api.middleware)}));return be(()=>e.setupListeners===!1?void 0:Me(R.dispatch,e.setupListeners),[e.setupListeners,R.dispatch]),ue.createElement(ke,{store:R,context:i},e.children)}var vt=Pe(Oe(),oe());export{Ue as ApiProvider,vt as createApi,oe as reactHooksModule,se as reactHooksModuleName};
//# sourceMappingURL=rtk-query-react.browser.mjs.map